#pragma once
#include <windows.h>
#include <d3d9.h>
#include <vector>
#include <utility>
using namespace std;

class cD3D9Enumer;
class cD3DAdapterInfo;
class cD3DDeviceInfo;
class cD3DDeviceSettingsCombo;
struct cD3DEnumDSMSConflicts;

cD3D9Enumer* GetEnumer();

class cD3D9Enumer
{
public:
	vector<cD3DAdapterInfo*>& GetAdapterInfoList(){
		return m_AdapterInfoList;
	}
	void DestroyD3D9Enum();
	HRESULT EnumAdapters(LPDIRECT3D9 pD3D9);
	HRESULT EnumDevice(cD3DAdapterInfo* pAdapterInfo,vector<D3DFORMAT>& vecAdapterFormat);
	HRESULT EnumDeviceCombo(cD3DAdapterInfo* pAdapterInfo,cD3DDeviceInfo* pDeviceInfo,
						vector<D3DFORMAT>& vecAdapterFormat);

	void SetDepthStencilFormatList();
	void SetMultiSampleTypeList();
	void SetPresentIntervalList();

	void BuildDepthStancilFormatList(cD3DDeviceSettingsCombo* pDeviceSettingsCombo);
	void BuildMultiSampleTypeList(cD3DDeviceSettingsCombo* pDeviceSettingsCombo);
	void BuildPresentIntervalList(cD3DDeviceSettingsCombo* pDeviceSettingsCombo,
								  cD3DDeviceInfo* pDeviceInfo);
	void BuildDSMSConflictsList(cD3DDeviceSettingsCombo* pDeviceSettingsCombo);

private:
	vector<cD3DAdapterInfo*> m_AdapterInfoList;

	vector<D3DFORMAT> m_DepthStencilFormatList;
	vector<D3DMULTISAMPLE_TYPE> m_MultiSampleTypeList;
	vector<UINT> m_PresentIntervalList;
	vector<cD3DEnumDSMSConflicts*> m_DSMSConflictsList;

	LPDIRECT3D9 m_pD3D9;
	
};


class cD3DAdapterInfo
{
public:
	~cD3DAdapterInfo();
	UINT AdapterOrdinal;
	D3DADAPTER_IDENTIFIER9 adapterIdentifier9;
	WCHAR szAdapterDescription[256];

	vector<D3DDISPLAYMODE> vecDisplayMode;
	vector<cD3DDeviceInfo*> vecDeviceInfo;
};

class cD3DDeviceInfo
{
public:
	~cD3DDeviceInfo();
	UINT AdapterOrdinal;
	D3DDEVTYPE devType;
	D3DCAPS9 Caps;

	vector<cD3DDeviceSettingsCombo*> vecDeviceSettingsCombo;
	vector<DWORD> vecBehaviorFlags;
};

class cD3DDeviceSettingsCombo
{
public:
	~cD3DDeviceSettingsCombo();
	UINT AdapterOrdinal;
	D3DDEVTYPE devType;
	D3DFORMAT BackBufferFormat;
	D3DFORMAT AdapterFormat;
	bool Windowed;

	vector<D3DFORMAT> vecDepthStencilFormat;
	vector<D3DMULTISAMPLE_TYPE> vecMultiSampleType;
	vector<DWORD> vecMultiSampleQuality;
	vector<UINT> vecPresentInterval;
	vector<cD3DEnumDSMSConflicts> vecDSMSConflictList;

	cD3DAdapterInfo* pAdapterInfo;
	cD3DDeviceInfo* pDeviceInfo;
};

struct cD3DEnumDSMSConflicts
{
	D3DFORMAT DSFormat;
	D3DMULTISAMPLE_TYPE MSType;
};







